#include <stdio.h>

int add(int a, int b) {
    return a + b;
}
int sub(int a, int b) {
    return a - b;
}
int mul(int a, int b) {
    return a * b;
}
int div(int a, int b) {
    if(b == 0) {
        printf("错误: 除数不能为0.\n");
        return 0;
    }
    return a / b;
}

int main() {
    int num1, num2, result;
    char operator;
    int count = 0;
    int numbers[100];
    char operators[100];

    // 提示用户输入
    printf("请输入一个简单的数学表达式（例如：2 + 3）：");
    scanf("%d", &numbers[count]);

    while(scanf(" %c %d", &operators[count], &numbers[count+1]) == 2) {
        count++;
    }

    // 计算结果
    result = numbers[0];
    for(int i = 0; i < count; i++) {
        if(operators[i] == '+') {
            result = add(result, numbers[i+1]);
        } else if(operators[i] == '-') {
            result = sub(result, numbers[i+1]);
        } else if(operators[i] == '*') {
            result = mul(result, numbers[i+1]);
        } else if(operators[i] == '/') {
            result = div(result, numbers[i+1]);
        } else {
            printf("错误: 输入的运算符不正确.\n");
            return 0;
        }
    }

    printf("结果为: %d\n", result);

    return 0;
}
